<?php
$this->layout()->disableLayout();
switch ($this->type) {
	case "javascript":
?>
dojo.xhrGet({
		url: '/cms/scripts/selectorWidget.js',
		handleAs: "javascript",
		sync: true
	});
dojo.xhrGet({
		url: '/cms/scripts/tabWidget.js',
		handleAs: "javascript",
		sync: true
	});


new mfSelectorsWidget('selectorBox',{defaultBoxClass:'mfSelectorWidget'});

new mfTabWidget('editAdminGroupsTabs');

dojo.query('#editAdminGroupsBackTab, #editAdminGroupsCloseBtn')
	.onclick(function () {
			dojo.destroy('editAdminGroupsBox');
			dojo.query('#adminListBox').removeClass('isHidden');
			dojo.destroy(editAdminStylesheet);
		});
		
dojo.query('#editAdminGroupsSubmitBtn').onclick(
	function () {
		dojo.xhrPost({
				url: '/cms/administrator/groups/type/save/id/<?= $this->administrator_id ?>',
				load: function(response, ioArgs) {
						if (response['ok']=='1') {
							dojo.destroy('editAdminGroupsBox');
							dojo.query('#adminListBox').removeClass('isHidden');
							dojo.destroy(editAdminStylesheet);
							dojo.publish('onsaveok',[]);
						}
					},
				error: function (response, ioArgs){
						alert("An error occurred, with response: " + response);
						return response;
					},
				form: 'editAdminGroupsFm',
				handleAs:"json",
				sunc: true
			});
		
	});
var editAdminStylesheet = dojo.create('link',{rel:'stylesheet',type:'text/css',href:'/cms/styles/selectorWidgetTheme.css'},dojo.query('head')[0]);
<?php 
		break;
	
	case "html":
?>
<ul id="editAdminGroupsTabs">
  <li><a class="isActive back" id="editAdminGroupsBackTab">Назад к списку администраторов</a></li>
  <li class="active"><a>Установка принадлежности групп</a></li>
</ul>
<div class="modalContent">
  <h1>Установка принадлежности групп</h1>
  <p class="stnd_font">Администратор: <?= $this->name ?> (<?= $this->login ?>)</p>
  <form id="editAdminGroupsFm">
    <div id="selectorBox">
    <?php foreach ($this->groupsList as $aGroup) : ?>
      <label>
      <input name="groupid[]" type="checkbox" value="<?= $aGroup[0] ?>" <?= $aGroup[2] ? ' checked="checked"' : ''?> /><?= $aGroup[1] ?></label>
    <?php endforeach; ?>
    </div>
  </form>
</div>
<div class="modalControls">
  <div class="controllGrad"></div>
  <div class="modalControlsBox">
    <input type="button" class="okButton" value="Сохранить" id="editAdminGroupsSubmitBtn" />
    <input type="button" class="okButton" value="Закрыть" id="editAdminGroupsCloseBtn" />
  </div>
</div>
<?php 	
		break;
	
	default:
?>

<?php 
	break;
}
?>